package com.trs.crypt;

import java.security.KeyException;

/**
 * @ClassName KeyAPI
 * @Description 描述
 * @Detail detail
 * @Author MyPC
 * @Date 2020/12/11
 * @Version 1.0
 */
public class KeyAPI {
    protected KeyAPI() {
    }

    public static final KeyAPI getInstance() throws KeyException {
        int DLLErrorCode = KeyJNIV124.getDLLErrorCode();
        switch(DLLErrorCode) {
            case 0:
                Class cls = null;
                Object api = null;

                try {
                    cls = KeyJNIV124.decryptClass((Object)null, 0L, (String)null, Thread.currentThread().getContextClassLoader(), (byte[])null);
                    api = cls.newInstance();
                } catch (Exception var4) {
                    throw new KeyException(var4.getMessage());
                }

                return (KeyAPI)api;
            case 1:
                throw new KeyException("JNI library not found:" + KeyJNIV124.getDLLErrorString());
            case 2:
                throw new KeyException("JNI library found, but can't link:" + KeyJNIV124.getDLLErrorString());
            case 3:
                throw new KeyException("JNI library version mismatch");
            default:
                throw new KeyException("JNI library link error, unknown");
        }
    }

    public String identifyHost() throws KeyException {
        throw new KeyException("Illegal Call, only for JNI");
    }

    public String getLocalIPs() throws KeyException {
        throw new KeyException("Illegal Call, only for JNI");
    }

    public String getLocalMACs() throws KeyException {
        throw new KeyException("Illegal Call, only for JNI");
    }

    public String generateDemo(String Signature, String Product, String Version, String License, String Custom) throws KeyException {
        throw new KeyException("Illegal Call, only for JNI");
    }

    public KeyInfo validateCode(String Signature, String KeyIn) throws KeyException {
        return this.validateCode(Signature, KeyIn, false);
    }

    public KeyInfo validateCode(String Signature, String KeyIn, boolean IgnoreDeadline) throws KeyException {
        throw new KeyException("Illegal Call, only for JNI");
    }

    public Class decryptClass(String ClassName, byte[] ClassData, ClassLoader ClassLoader) throws KeyException {
        throw new KeyException("Illegal Call, only for JNI");
    }

    public byte[] encryptClass(String ClassName, byte[] ClassData) throws KeyException {
        throw new KeyException("Illegal Call, only for JNI");
    }

    public static void main(String[] args) throws Exception {
        try {
            KeyAPI api = getInstance();
            System.out.println(api.identifyHost());
        } catch (KeyException var2) {
            System.out.println(var2.getMessage());
            throw var2;
        }
    }
}
